#include <stdio.h>
#include <string.h>

int main() {
    int L,M;
    int map[100000];
    memset(map,0,sizeof(map));
    scanf("%d%d",&L,&M);
    for (int i=0;i<M;i++) {
        int from,to;
        scanf("%d%d",&from,&to);
        for (int j=from;j<=to;j++) map[j]=1;
    }
    int tot=0;
    for (int i=0;i<=L;i++) tot+=!map[i];
    printf("%d",tot);
}